<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<title></title>
  <style type="text/css">
    <!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
  </style>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head><body>


<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- =   Java2Html Converter 4.2 [2006-01-05] by Markus Gebhard  markus@jave.de   = -->
<!-- =     Further information: http://www.java2html.de     = -->
<div align="left" class="java">
<table border="2" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
  <!-- start headline -->
   <tr>
    <td colspan="2">
     <center><font size="+2">
      <code><b>
Execution.java
      </b></code>
     </font></center>
    </td>
   </tr>
  <!-- end headline -->
   <tr>
  <!-- start source code -->
   <td nowrap="nowrap" valign="top" align="left">
    <code>
<font color="#808080">01</font>&nbsp;<font color="#7f0055"><b>package&nbsp;</b></font><font color="#000000">org.jbpm.gop;</font><br />
<font color="#808080">02</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">03</font>&nbsp;<font color="#7f0055"><b>import&nbsp;</b></font><font color="#000000">java.util.List;</font><br />
<font color="#808080">04</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">05</font>&nbsp;<font color="#3f5fbf">/**&nbsp;one&nbsp;path&nbsp;of&nbsp;execution&nbsp;*/</font><br />
<font color="#808080">06</font>&nbsp;<font color="#7f0055"><b>public&nbsp;class&nbsp;</b></font><font color="#000000">Execution&nbsp;</font><font color="#000000">{</font><br />
<font color="#808080">07</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">08</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;pointer&nbsp;to&nbsp;the&nbsp;current&nbsp;node&nbsp;*/&nbsp;</font><br />
<font color="#808080">09</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">Node&nbsp;node&nbsp;=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">;</font><br />
<font color="#808080">10</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">11</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;an&nbsp;execution&nbsp;always&nbsp;starts&nbsp;in&nbsp;a&nbsp;given&nbsp;node&nbsp;*/</font><br />
<font color="#808080">12</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">Execution</font><font color="#000000">(</font><font color="#000000">Node&nbsp;node</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">13</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>this</b></font><font color="#000000">.node&nbsp;=&nbsp;node;</font><br />
<font color="#808080">14</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">15</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">16</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;executes&nbsp;the&nbsp;current&nbsp;node's&nbsp;actions&nbsp;and&nbsp;takes&nbsp;the&nbsp;event's&nbsp;transition&nbsp;*/</font><br />
<font color="#808080">17</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">event</font><font color="#000000">(</font><font color="#000000">String&nbsp;event</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">18</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">+</font><font color="#2a00ff">&#34;&nbsp;received&nbsp;event&nbsp;'&#34;</font><font color="#000000">+event+</font><font color="#2a00ff">&#34;'&nbsp;on&nbsp;&#34;</font><font color="#000000">+node</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">19</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">fire</font><font color="#000000">(</font><font color="#000000">event</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">20</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">node.transitions.containsKey</font><font color="#000000">(</font><font color="#000000">event</font><font color="#000000">))&nbsp;{</font><br />
<font color="#808080">21</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">+</font><font color="#2a00ff">&#34;&nbsp;leaves&nbsp;&#34;</font><font color="#000000">+node</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">22</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">fire</font><font color="#000000">(</font><font color="#2a00ff">&#34;leave-node&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">23</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">take</font><font color="#000000">(</font><font color="#000000">node.transitions.get</font><font color="#000000">(</font><font color="#000000">event</font><font color="#000000">))</font><font color="#000000">;</font><br />
<font color="#808080">24</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">25</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">26</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">27</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;take&nbsp;a&nbsp;transition&nbsp;*/</font><br />
<font color="#808080">28</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">take</font><font color="#000000">(</font><font color="#000000">Transition&nbsp;transition</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">29</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">+</font><font color="#2a00ff">&#34;&nbsp;takes&nbsp;transition&nbsp;to&nbsp;&#34;</font><font color="#000000">+transition.destination</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">30</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">node&nbsp;=&nbsp;transition.destination;</font><br />
<font color="#808080">31</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">enter</font><font color="#000000">(</font><font color="#000000">transition.destination</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">32</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">33</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">34</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;enter&nbsp;the&nbsp;next&nbsp;node&nbsp;*/</font><br />
<font color="#808080">35</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">enter</font><font color="#000000">(</font><font color="#000000">Node&nbsp;node</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">36</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">+</font><font color="#2a00ff">&#34;&nbsp;enters&nbsp;&#34;</font><font color="#000000">+node</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">37</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">fire</font><font color="#000000">(</font><font color="#2a00ff">&#34;enter-node&#34;</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">38</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">node.execute</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">39</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">40</font>&nbsp;<font color="#ffffff"></font><br />
<font color="#808080">41</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;fires&nbsp;the&nbsp;actions&nbsp;of&nbsp;a&nbsp;node&nbsp;for&nbsp;a&nbsp;specific&nbsp;event&nbsp;*/</font><br />
<font color="#808080">42</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">fire</font><font color="#000000">(</font><font color="#000000">String&nbsp;event</font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">43</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">List&lt;Action&gt;&nbsp;eventActions&nbsp;=&nbsp;node.actions.get</font><font color="#000000">(</font><font color="#000000">event</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">44</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">eventActions!=</font><font color="#7f0055"><b>null</b></font><font color="#000000">)&nbsp;{</font><br />
<font color="#808080">45</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">+</font><font color="#2a00ff">&#34;&nbsp;fires&nbsp;actions&nbsp;for&nbsp;event&nbsp;'&#34;</font><font color="#000000">+event</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">46</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>for&nbsp;</b></font><font color="#000000">(</font><font color="#000000">Action&nbsp;action&nbsp;:&nbsp;eventActions</font><font color="#000000">)&nbsp;</font><br />
<font color="#808080">47</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">action.execute</font><font color="#000000">(</font><font color="#7f0055"><b>this</b></font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#808080">48</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">49</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br />
<font color="#808080">50</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><br />
<font color="#808080">51</font>&nbsp;<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">String&nbsp;toString</font><font color="#000000">()&nbsp;{</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#2a00ff">&#34;execution&#34;</font><font color="#000000">;</font><font color="#000000">}</font><br />
<font color="#808080">52</font>&nbsp;<font color="#000000">}</font></code>
    
   </td>
  <!-- end source code -->
   </tr>
</table>
</div>
<!-- =       END of automatically generated HTML code       = -->
<!-- ======================================================== -->


</body></html>